package it.unicam.cs.cosy.bioshape.core.collisiondetection.narrowphase;

import java.util.List;

import it.unicam.cs.cosy.bioshape.core.behaviours.ActiveSite;
import it.unicam.cs.cosy.bioshape.core.components.EntityPair;

/**
 * General interface for the broad phase of the collision detection. All the
 * provided narrow phase implementations must adhere to this interface.
 * 
 * @author Federico Buti
 */
public interface NarrowPhase {

	/**
	 * @return the list of features which are active and able to react
	 */
	ActiveSite[] getContactSurfaces();

	/**
	 * @return the set of colliding pairs of entities which could be
	 *         {@code empty} if no collision occurs in the curren timestep
	 */
	public List<EntityPair> getPairs();

	/**
	 * Calculates the FTC (First Time of Contact). The general contract of this
	 * method is to return the FTC or {@code Double.POSITIVE_INFINITY} if no
	 * contact at all occurs between the entities.
	 * 
	 * @param p
	 *            a list of {@code EntityPair}.
	 * @param t
	 *            The time interval into which search for the FTC.
	 * 
	 * @return A {@code double} representing the first time of contact.
	 * @throws SearchingErrorException
	 *             Thrown if during the search for the FTC something goes wrong.
	 *             Strictly implementation dependant.
	 */
	double getFTC(List<EntityPair> p, double t) throws SearchingErrorException;
}